import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { TestDetailsButton, ExecuteButton, ExamineFillButton } from '../Common/options'
import { MixPlatHandleType, ProjectList } from '../Common/Conversion'

export const LabAsphaltMixingStationExceeded = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    const { hostname } = window.location
    const mixPlatHandleType = await MixPlatHandleType()
    let data = {
        type: '拌合站',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        columns: [
            commonTableList.uuid,
            { ...commonTableList.SearchSort, selectType: 'LabAsphaltMixingStationExceeded' },
            {
                ...commonTableList.projectUuid,
                valueEnum: await ProjectList(),
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
                hideInSearch: !hostname.includes('jszx'),
            },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            { ...commonTableList.StartTime, hideInTable: true },
            { ...commonTableList.EndTime, hideInTable: true },
            {
                dataIndex: 'matName',
                title: '预警分类',
                valueType: 'select',
                valueEnum: BuiltInData.matName,
                align: 'center',
                width: 150,
            },
            {
                dataIndex: 'alarmlve',
                title: '报警等级',
                valueType: 'select',
                valueEnum: BuiltInData.alarmlve,
                align: 'center',
                width: 150,
            },
            {
                dataIndex: 'uporDown',
                title: '报警类型',
                valueType: 'select',
                valueEnum: BuiltInData.uporDown,
                align: 'center',
                width: 150,
            },
            {
                dataIndex: 'dischargingTime',
                title: '出料时间',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'equipmentCode',
                title: '设备编号',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'engineeringName',
                title: '工程名称',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'constructionSite',
                title: '施工地点',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'layerPosition',
                title: '使用层位',
                valueType: 'select',
                valueEnum: BuiltInData.layerPosition,
                width: 150,
            },
            {
                dataIndex: 'proportionIdGet',
                title: '配合比编号(名称)',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'temperature',
                title: '出料温度',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'asphaltAggregateRatioAct',
                title: '油石比(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'asphaltAct',
                title: '施工沥青用量(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'sand1Act',
                title: '骨料1(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'sand2Act',
                title: '骨料2(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'gravel1Act',
                title: '骨料3(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'gravel2Act',
                title: '骨料4(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'gravel3Act',
                title: '骨料5(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'gravel4Act',
                title: '骨料6(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'slagPowderAct',
                title: '矿粉(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'cement1Act',
                title: '水泥(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'recycledMaterialAct',
                title: '再生料(实际)',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            commonTableList.isEnabled,
            {
                dataIndex: 'mixPlatHandleTypeUuid',
                title: '处理意见',
                valueType: 'select',
                hideInSearch: true,
                valueEnum: mixPlatHandleType,
                width: 180,
            },
            {
                dataIndex: 'remark',
                title: '意见说明',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'handleUserName',
                title: '审核人',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'handleTime',
                title: '审核时间',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'handleUserName',
                title: '审核人',
                valueType: 'input',
                hideInSearch: true,
                width: 150,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 350,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { asphaltMixingStationDataUuid, mixPlatHandleTypeUuid, isEnabled, uuid, dataNumber } = record
                    return [
                        <TestDetailsButton
                            key="test"
                            title="查看详情"
                            OptionsEvent={OptionsEvent}
                            data={{
                                type: 'LabAsphalt',
                                title: '沥青拌合站详情',
                                data: { uuid, url: 'getLabAsphaltID' },
                            }}
                        />,
                        <TestDetailsButton
                            key="centralized"
                            title="级配"
                            OptionsEvent={OptionsEvent}
                            data={{
                                type: 'LabAsphaltCentralized',
                                title: '沥青拌合站级配',
                                data: { uuid: dataNumber },
                            }}
                        />,

                        Permission.findIndex(v => v.uuid === '201be848-9fb6-4840-8363-e1dcd749b8ee') !== -1 &&
                            !mixPlatHandleTypeUuid && (
                                <ExamineFillButton
                                    key="Examine"
                                    OptionsEvent={OptionsEvent}
                                    title="处理意见"
                                    data={{
                                        options: mixPlatHandleType,
                                        groupId: uuid,
                                        url: 'posAsphaltExceededDatasUpdateRemark',
                                        actionRef,
                                    }}
                                />
                            ),
                        // Permission.findIndex(v => v.uuid === '201be848-9fb6-4840-8363-e1dcd749b8ee') !== -1 && (
                        //     <LabDetailsBtn
                        //         key="modal"
                        //         uuid={asphaltMixingStationDataUuid}
                        //         title="级配信息"
                        //         type="AsphaltCurveDatasModal"
                        //     />
                        // ),
                        Permission.findIndex(v => v.uuid === '201be848-9fb6-4840-8363-e1dcd749b8ee') !== -1 &&
                            isEnabled === 0 && (
                                <ExecuteButton
                                    actionRef={actionRef}
                                    key="one"
                                    title="启用"
                                    url="patlabAsphalts"
                                    path={[asphaltMixingStationDataUuid, 1]}
                                    tips="数据启用成功!"
                                />
                            ),
                        Permission.findIndex(v => v.uuid === '201be848-9fb6-4840-8363-e1dcd749b8ee') !== -1 &&
                            isEnabled === 1 && (
                                <ExecuteButton
                                    actionRef={actionRef}
                                    key="two"
                                    title="禁用"
                                    danger={true}
                                    url="patlabAsphalts"
                                    path={[asphaltMixingStationDataUuid, 0]}
                                    tips="数据禁用成功!"
                                />
                            ),
                    ]
                },
            },
        ],
    }
    return data
}
